$(function(){

  var screenWidth = $(window).width();
  var video = [
  	{
      img: basePath + "images/shade_04.png",
	  m4v:"http://www.chyjr.com/photo/style/video/ad/ad04.mp4"
    },
    {
      img: basePath + "images/bg-01.png",
      m4v:"http://www.chyjr.com/photo/style/video/ad/ad01.mp4"
    },
    {
      img: basePath + "images/shade_02.jpg",
      m4v:"http://www.chyjr.com/photo/style/video/ad/ad02.mp4"
    },
    {
      img: basePath + "images/shade_03.jpg",
      m4v:"http://www.chyjr.com/photo/style/video/ad/ad03.mp4"
    }
      /*,
    {
      img: basePath + "/static/images/brand/bg-01.png",
      m4v:"http://www.chyjr.com/photo/style/video/ad/ad01.mp4"
    },
    {
      img: basePath + "/static/images/hyabout/shade_02.jpg",
      m4v:"http://www.chyjr.com/photo/style/video/ad/ad02.mp4"
    },
    {
      img: basePath + "/static/images/hyabout/shade_03.jpg",
      m4v:"http://www.chyjr.com/photo/style/video/ad/ad03.mp4"
    }*/
  ];




  //视频图片轮播
  /*$("#temp4").Slide({
    effect : "scroolLoop",
    autoPlay:false,
    speed : "normal",
    timer : 3000,
    steps:2
  });*/
  //点击图标显示与隐藏
  if(screenWidth >= 768) {
    $(".hover-img").hover(function(){
      $(".open-img").eq($(this).index()).hide();
    },function(){
      $(".open-img").eq($(this).index()).show();
    });

  }


    var dataIndex = 0;
    /*$(".btn-sign").click(function(){
      var screenWidth = $(window).width();
      if (screenWidth >= 768) {
         $(".alert").show();
      }
      if($(this).attr('data-index')) {
        dataIndex = $(this).attr('data-index');
      }
      console.log("dataIndex=",dataIndex);
      var imgSrc = video[dataIndex].img;
      var videoSrc = video[dataIndex].m4v;
      console.log("videoSrc=",videoSrc);
      $("#jquery_jplayer_1").jPlayer({
        ready: function () {
          $(this).jPlayer("setMedia", {
            title: "海银财富",
            m4v: videoSrc,
            poster: imgSrc
          }).jPlayer("play");
        },
        swfPath: basePath + "/static/js/jPlayer/dist/jplayer",
        supplied: "webmv, ogv, m4v",
        size:{
          width:"100%",
          height:'100%',
          cssClass:"jp-video-360p"
        },
        useStateClassSkin: true,
        autoBlur: false,
        smoothPlayBar: true,
        keyEnabled: true,
        remainingDuration: true,
        toggleDuration: true
      }).jPlayer("repeat");
      $('.hy-view-close').click(function() {
        $(".alert").hide();
        $("#jquery_jplayer_1").jPlayer('stop');
      })
    })*/

    $(".btn-sign").click(function() {
      if($(this).attr('data-index')) {
        dataIndex = $(this).attr('data-index');
      }
      $('.view-file .view-shade .alert').eq(dataIndex).show().siblings('.alert').hide();
    });
    $('.jp-video-play-icon').click(function(event) {
      /* Act on the event */
      $(this).parent('div').hide();
      $(this).parents('.jp-gui').siblings('.jp-jplayer').find('img').hide();
      $(this).parents('.jp-gui').siblings('.jp-jplayer').find('video').show();
    });

    $("#jquery_jplayer_01").jPlayer({
      ready: function () {
        $(this).jPlayer("setMedia", {
          title: "海银财富",
          m4v: "http://www.chyjr.com/photo/style/video/ad/ad01.mp4",
          poster: basePath + "images/bg-01.png"
        });
      },
      play: function() { // To avoid multiple jPlayers playing together.
        $(this).jPlayer("pauseOthers");
      },

      swfPath: basePath + "js/bootstrap/jplayer",
      supplied: "webmv, ogv, m4v",
      size:{
        width:"100%",
        height:'453px',
        cssClass:"jp-video-360p"
      },
      cssSelectorAncestor:'#jp_container_01',
      useStateClassSkin: true,
      autoBlur: false,
      smoothPlayBar: true,
      keyEnabled: true,
      remainingDuration: true,
      toggleDuration: true
    });

    $("#jquery_jplayer_02").jPlayer({
      ready: function () {
        $(this).jPlayer("setMedia", {
          title: "海银财富",
          m4v: "http://www.chyjr.com/photo/style/video/ad/ad02.mp4",
          poster: basePath + "images/shade_02.jpg"
        });
      },
      play: function() { // To avoid multiple jPlayers playing together.
        $(this).jPlayer("pauseOthers");
      },
      swfPath: basePath + "js/bootstrap/jplayer",
      supplied: "webmv, ogv, m4v",
      size:{
        width:"100%",
        height:'453px',
        cssClass:"jp-video-360p"
      },
      cssSelectorAncestor:'#jp_container_02',
      useStateClassSkin: true,
      autoBlur: false,
      smoothPlayBar: true,
      keyEnabled: true,
      remainingDuration: true,
      toggleDuration: true
    });

    $("#jquery_jplayer_03").jPlayer({
      ready: function () {
        $(this).jPlayer("setMedia", {
          title: "海银财富",
          m4v: "http://www.chyjr.com/photo/style/video/ad/ad03.mp4",
          poster: basePath + "images/shade_03.jpg"
        });
      },
      play: function() { // To avoid multiple jPlayers playing together.
        $(this).jPlayer("pauseOthers");
      },
      swfPath: basePath + "/static/bootstrap/jplayer",
      supplied: "webmv, ogv, m4v",
      size:{
        width:"100%",
        height:'453px',
        cssClass:"jp-video-360p"
      },
      cssSelectorAncestor:'#jp_container_03',
      useStateClassSkin: true,
      autoBlur: false,
      smoothPlayBar: true,
      keyEnabled: true,
      remainingDuration: true,
      toggleDuration: true
    });

	$("#jquery_jplayer_04").jPlayer({
		ready: function () {
			$(this).jPlayer("setMedia", {
				title: "海银财富",
				m4v: "http://www.chyjr.com/photo/style/video/ad/ad04.mp4",
				poster: basePath + "images/shade_04.jpg"
			});
		},
		play: function() { // To avoid multiple jPlayers playing together.
			$(this).jPlayer("pauseOthers");
		},
		swfPath: basePath + "/static/bootstrap/jplayer",
		supplied: "webmv, ogv, m4v",
		size:{
			width:"100%",
			height:'453px',
			cssClass:"jp-video-360p"
		},
		cssSelectorAncestor:'#jp_container_04',
		useStateClassSkin: true,
		autoBlur: false,
		smoothPlayBar: true,
		keyEnabled: true,
		remainingDuration: true,
		toggleDuration: true
	});






  //获取点击
  $(".JQ-slide-content li").click(function(){
    var idx = $(this).index();
    var imgSrc = video[idx].img;
    $('.view-file .view-shade .alert').eq(idx).show().siblings('.alert').hide();
    // $("#shade").attr("src",imgSrc);
    $(".btn-sign").attr('data-index', idx);
    $("#jquery_jplayer_01").jPlayer('pause');
    $("#jquery_jplayer_02").jPlayer('pause');
    $("#jquery_jplayer_03").jPlayer('pause');
	$("#jquery_jplayer_04").jPlayer('pause');

    $("#jquery_jplayer_01").siblings('.jp-gui').find(".jp-video-play").show();
    $("#jquery_jplayer_02").siblings('.jp-gui').find(".jp-video-play").show();
    $("#jquery_jplayer_03").siblings('.jp-gui').find(".jp-video-play").show();
	$("#jquery_jplayer_04").siblings('.jp-gui').find(".jp-video-play").show();
    /*$("#jp_poster_0").show();
    $("#jp_poster_1").show();
    $("#jp_poster_2").show();*/
  })



})
